<template>
<view>
	<view class="list" v-for="(item,index) in list" :key="index">
		<view class="item" v-if="role ==2">{{item.company_name}}请求查看你的电话</view>
		<view class="item" v-else>{{item.realname}}已同意您的电话查看请求</view>
		<view class="line_footer" v-if="role ==2">
			<view class="left1" @click="confirm(item.id,2,index)">同意</view>
			<view class="left" @click="confirm(item.id,3,index)">拒绝</view>
		</view>
		<view class="line_footer" v-else>
			<view class="left" @click="confirm(item.id,4,index)">不在提醒</view>
			<view class="right" @click="toUser(item.uid)">查看</view>
		</view>
	</view>
</view>
</template>
<script>
import request from '@/util/request.js'
export default {
	data() {
		return {
			avatarUrl: '/static/qrcode.jpg',
			nickName:'',
			role:0,
			list:[]
		}
	},
	onLoad:function() {
		this.role = uni.getStorageSync('role')
		uni.showLoading({
		    title: '加载中'  
		});
		this.getList()
	},
	methods: {
		getList:function(){
			var that = this
			var data = {'uid':uni.getStorageSync('uid')}
			request({
				url: 'phoneSee/list',
				method: 'get',
				data:data,
				success: (res) => {
					console.log(res)
					uni.hideLoading()
					that.list = res.data.data
				}
			})
		},
		toUser:function(uid){
			uni.navigateTo({
				url:'/pages/job/info?uid='+uid
			});
		},
		confirm:function(id,type,index){
			var that = this
			var data ={id:id,type:type}
			request({
				url: 'phoneSee/edit',
				method: 'put',
				data:data,
				success: (res) => {
					uni.hideLoading()
					if(res.data.code == 1){
						uni.showToast({
							title: '成功!!!',
							icon: "success", 
							position:'bottom',
						});
						that.list.splice(index,1)
					}
				}
			})
		},
		jump:function(url){
			uni.navigateTo({
			  url:url
			})
		}
	}
}
</script>
<style>
.list{
	display: flex;
	flex-direction: column;
	padding: 15rpx 15rpx 20rpx 20rpx;
	border-bottom: 5rpx solid #CCCCCC;
}
.item{
	font-weight: 900;
	font-size:15px;
	height: 80rpx;
	line-height: 80rpx;
}
.line_footer{
	width:100%;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
}
.left{
	width:150rpx;
	height:60rpx;
	line-height: 60rpx;
	border-radius: 30rpx;
	color:#FFFFFF;
	background: #e60000;
	font-size:12px;
	text-align: center;
}
.left1{
	width:150rpx;
	height:60rpx;
	line-height: 60rpx;
	border-radius: 30rpx;
	color:#FFFFFF;
	background: #00b359;
	font-size:12px;
	text-align: center;
}
.right{
	width:150rpx;
	height:60rpx;
	line-height: 60rpx;
	border-radius: 30rpx;
	color:#FFFFFF;
	background: #0000e6;
	font-size:12px;
	text-align: center;
}
</style>